#########################################################################
##
## This file is part of the SAMRAI distribution.  For full copyright 
## information, see COPYRIGHT and LICENSE. 
##
## Copyright:     (c) 1997-2019 Lawrence Livermore National Security, LLC
## Description:   makefile for testing variable database operations 
##
#########################################################################

SAMRAI        = @top_srcdir@
SRCDIR        = @srcdir@
SUBDIR        = source/test/variables
VPATH         = @srcdir@
TESTTOOLS     = ../testtools
OBJECT        = ../../..
REPORT        = $(OBJECT)/report.xml

default: check

include $(OBJECT)/config/Makefile.config

CPPFLAGS_EXTRA	= -DTESTING=1

CXX_OBJS	= main-var_db.o

main:	$(CXX_OBJS) $(LIBSAMRAIDEPEND)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(CXX_OBJS) \
	$(LIBSAMRAI2D) $(LIBSAMRAI) $(LDLIBS) -o $@

NUM_TESTS  = 1

TEST_NPROCS = @TEST_NPROCS@
QUOTE = \"

checkcompile: main

check:
	$(MAKE) check2d
	$(MAKE) check3d

check2d:	checkcompile
	@for p in `echo "$(TEST_NPROCS)" | tr "," " "`; do \
	  echo "    <testcase classname=\"variables\" name=$(QUOTE)$$p procs$(QUOTE)>" >> $(REPORT); \
	  $(OBJECT)/config/serpa-run $$p ./main | $(TEE) foo; \
	  if ! grep "PASSED" foo >& /dev/null ; then echo "      <failure/>" >> $(REPORT); fi; \
	  echo "    </testcase>" >> $(REPORT); \
	done; \
	$(RM) foo

check3d:

checktest:
	$(RM) makecheck.logfile
	$(MAKE) check 2>&1 | $(TEE) makecheck.logfile
	$(TESTTOOLS)/testcount.sh $(TEST_NPROCS) $(NUM_TESTS) 0 makecheck.logfile
	$(RM) makecheck.logfile

examples:

perf:

everything:
	$(MAKE) checkcompile || exit 1
	$(MAKE) checktest
	$(MAKE) examples
	$(MAKE) perf

checkclean:
	$(CLEAN_COMMON_CHECK_FILES)

clean:	checkclean
	$(CLEAN_COMMON_TEST_FILES)
	$(RM) main

include $(SRCDIR)/Makefile.depend
